package com.tanhua.manage.controller;


import com.tanhua.common.pojo.PageResult;
import com.tanhua.manage.pojo.DongJie;
import com.tanhua.manage.pojo.UnDongJie;
import com.tanhua.manage.pojo.UsersMaterial;
import com.tanhua.manage.service.UsersServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("manage")
public class UsersController {
    @Autowired
    UsersServiceImpl usersService;

    @GetMapping("/users")
    public PageResult users(@RequestParam Integer pagesize, @RequestParam Integer page) {
        PageResult users = usersService.users(pagesize, page);
        return users;
    }

    @GetMapping("/users/{uid}")
    public UsersMaterial yonghuziliao(@PathVariable("uid") Long userid) {
        UsersMaterial usersMaterial = usersService.usersMaterial(userid);
        return usersMaterial;
    }

    @PostMapping("/users/freeze")
    public Map<String, String> freeze(@RequestBody DongJie freeze) {
        Map<String, String> free = usersService.free(freeze);
        return free;
    }

    @PostMapping("/users/unfreeze")
    public Map<String, String> unfreeze(@RequestBody UnDongJie unfreeze) {
        Map<String, String> unfreeze1 = usersService.unfreeze(unfreeze);
        return unfreeze1;
    }

}
